<?php

namespace App\Modules\Admin\Controllers;

use App\Http\Resources\Admin\MenuOptionResource;
use App\Http\Resources\Admin\PermissionResource;
use App\Modules\Admin\Services\PermissionService;
use Illuminate\Http\Request;

class MenuController extends AdminController
{
    public function routes(PermissionService $service)
    {
        return $this->responseSuccess($service->routes());
    }

    public function index(Request $request, PermissionService $service)
    {
        return $this->responseSuccess(PermissionResource::collection($service->options($request->all())));
    }

    public function add(Request $request, PermissionService $service)
    {
        return $this->responseSuccess($service->add($request->all()));
    }

    public function edit(Request $request, Int $id, PermissionService $service)
    {
        return $this->responseSuccess($service->edit($id, $request->all()));
    }

    public function detail(Int $id, PermissionService $service)
    {
        return $this->responseSuccess($service->detail($id));

    }

    public function del(Int|String $id, PermissionService $service)
    {
        return $this->responseSuccess($service->del($id));
    }

    public function options(PermissionService $service)
    {
        return $this->responseSuccess(MenuOptionResource::collection($service->options()));
    }
}
